<table id="service_serviceGroupInfo_data"></table> 
<script>
$(function(){
	$('#service_serviceGroupInfo_data').datagrid({   
	    url:'../servicesGroupInfoServlet',
	    queryParams:{op:"getServicesGroupInfo"},   
	    loadMsg:'数据加载中...',
	    fitColumns:true,
	    pagination:true,
	    rownumbers:true,
	    striped:true,
	    sortName:'sgid',
	    sortOrder:'asc',
	    remoteSort:false,
	    pageNumber:1, 
		pageSize:10, 
		pageList:[10,20,30,40,50],
	    columns:[[  
	       
	        {field:'sgid',title:'成员编号',width:150,align:'center',sortable:true},   
	        {field:'sgname',title:'成员姓名',width:150,align:'center'},   
	        {field:'sgimgpath',title:'头像',width:300,align:'center',
	        	formatter:function(value,row,index){return '<img width="100" height="100" src="../'+row.sgimgpath+'" />';}
	        },
	        {field:'sgtype',title:'所属团队类别',width:150,align:'center'}   
	    ]],
	    toolbar: [{
	    	text:'添加',
			iconCls: 'icon-add',
			handler: function(){
				$("#service_serviceGroupInfo_data_add").dialog("open");
			}
		},'-',{
			text:'删除',
			iconCls: 'icon-remove',
			handler: function(){
				//获取所有被选中的行
				var rows=$('#service_serviceGroupInfo_data').datagrid("getChecked");
				if(rows.length<=0){ //说明没有选中
					$.messager.show({
						title:'温馨提示',
						msg:'请选择您要删除的数据....',
						timeout:2000,
						showType:'slide'
					});
				}else{
					$.messager.confirm('信息确认', '您确定要删除选中的记录吗?', function(r){
						if (r){
							var aids="";
							//获取所有选中的数据的id
							for(var i=0;i<rows.length-1;i++){
								aids+=rows[i].sgid+",";
							}
							aids+=rows[i].sgid;
							
							//向服务器发送请求
							$.post("../servicesGroupInfoServlet?t="+new Date(),{op:"delServiceGroupInfo",aids:aids},function(data){
								data=parseInt( $.trim(data) );
								if(data>0){
									$.messager.show({
										title:'成功提示',
										msg:'服务团队信息删除成功....',
										timeout:3000,
										showType:'slide'
									});
									$('#service_serviceGroupInfo_data').datagrid("reload");
								}else{
									$.messager.alert('失败提示','服务团队信息删除失败，请稍后重试...','error');
								}
							});
						}
					});
				}
			}
		},'-',{
			text:'修改',
			iconCls: 'icon-edit',
			handler: function(){
				var rows=$('#service_serviceGroupInfo_data').datagrid("getChecked");
				if(rows.length<=0){
					$.messager.show({title:'温馨提示',msg:'请选择您要修改的数据....',timeout:2000,showType:'slide'});
				}else{
					$("#service_serviceGroupSgname_update").val( rows[0].sgname );
					$("#service_serviceGroupSgtype_update").val( rows[0].sgtype );
					$("#service_serviceGroupSgid_update").val(rows[0].sgid);
					//$("#admin_adminPwd_update").val( rows[0].pwd );
					$("#service_serviceGroupInfo_data_update").dialog("open");
				}
			}
		}]
	});
})

$("#service_serviceGroupInfo_data").datagrid('getPager').pagination({
	beforePageText:'第',
	afterPageText:'页  共{pages}页',
	displayMsg:'当前显示 {from}-{to} 条记录  共{total} 条记录'
})




//修改管理员信息
function service_updateInfo(){
	var sgname=$.trim( $("#service_serviceGroupSgname_update").val() );
	var sgtype=$.trim( $("#service_serviceGroupSgtype_update").val() );
	var sgid=$.trim($("#service_serviceGroupSgid_update").val());
	
	$.post("../servicesGroupInfoServlet?t="+new Date(),{op:"updateServiceGroupInfo",sgname:sgname,sgtype:sgtype,sgid:sgid},function(data){
		data=parseInt( $.trim(data) );
		if(data>0){
			$.messager.show({
				title:'成功提示',
				msg:'服务团队信息修改成功....',
				timeout:3000,
				showType:'slide'
			});
			$("#service_serviceGroupSgname_update").val("");
			$("#service_serviceGroupSgtype_update").val("");
			
			$("#service_serviceGroupInfo_data_update").dialog("close"); //关闭添加对话框
			$('#service_serviceGroupInfo_data').datagrid("reload");
		}else{
			$.messager.alert('失败提示','服务团队信息修改失败，请稍后重试...','error');
		}
	});
}
</script>

<div id="service_serviceGroupInfo_data_add" class="easyui-dialog" title="添加服务团队信息" style="width:400px;height:200px;" 
	data-options="iconCls:'icon-add',resizable:true,modal:true,closed:true">  
   <br /><br />
   <center>
   <label for="service_serviceName">姓名：</label><input type="text" id="service_serviceName"><br /><br />
   &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<label for="service_serviceImgpath">头像：<input name="pic" id="service_pic" type="file" multiple="multiple"/>  <br/>  <br/>
   <label for="service_serviceClickpath">路径：</label><input type="text" id="service_serviceClickpath"><br /><br />
   <label for="service_serviceType">类别：</label><input type="text" id="service_serviceType"><br /><br />
    
    <input type="button" onclick="service_addInfo()" value="添加"/>
    </center> 
</div> 

<div id="service_serviceGroupInfo_data_update" class="easyui-dialog" title="修改服务团队员信息" style="width:400px;height:200px;" 
	data-options="iconCls:'icon-edit',resizable:true,modal:true,closed:true">  
   <br /><br />
   <input type="hidden" id="service_serviceGroupSgid_update">
   <center><label for="service_serviceGroupSgname_update">姓名：</label><input type="text" id="service_serviceGroupSgname_update"><br /><br />
    <label for="service_serviceGroupSgtype_update">类别：</label><input type="text" id="service_serviceGroupSgtype_update"><br /><br />
    <input type="button" onclick="service_updateInfo()" value="修改"/></center> 
</div>   

<script>
	
    
    function service_addInfo(){
    	var sgname=$("#service_serviceName").val();
    	var sgclickpath=$("#service_serviceClickpath").val();
    	var sgtype=$("#service_serviceType").val();
    	
    	
    	$.ajaxFileUpload({
    		url:"../servicesGroupInfoServlet?op=addServiceGroupInfo",
    		secureuri:false,
    		fileElementId:"service_pic",
    		dataType:"json",
    		data:{"sgname":sgname,"sgclickpath":sgclickpath,"sgtype":sgtype},
    		success:function(data,status){
    			if(parseInt($.trim(data))==1){
    				$.messager.show({
    					title:'成功提示',
						msg:'服务团队信息上传成功...',
						timeout:2000,
						showType:'slide'
    				});
    				$('#service_serviceGroupInfo_data').datagrid("reload");
    				$("#service_serviceGroupInfo_data_add").dialog("close");
    				
    			}else{
    				$.messager.alert('失败提示','服务团队信息添加失败，请稍后再试...','error');
    			}
    		},
    		error:function(data,status,e){
    			$.messager.alert('失败提示','服务团队信息添加失败，请稍后再试...','error');
    		}
    	});
    }
</script>
